Architecture Specification
Architecture Specification CRC Cards Keep in mind that only either the Wii Controller or Mouse Controller is active at a time. Mouse Controller Description This module reads the mouse state, converts it into the standardized Input State, and adds it to the Input Buffer. Single Module Justification This is separate from the Wii Controller because the control methods use different libraries and provide needed input data in different formats. Wii Controller Description This is parallel to the Mouse Controller. This module reads the Wiimote state, converts it into the standardized Input State, and adds it to the Input Buffer. Single Module Justification It is separate from the Mouse Controller because the control methods use different libraries and provide needed input data in different formats. Level Controller Description This module drives all components used in the rhythm section of the game. It keeps track of where the player is in the song, and it updates the score as the song progresses. It can be considered a controller. It also handles the drawing of HUD related displays. Single Module Justification Level Controller processes information of the current play level, which includes current beat, movement, score, etc. In addition, it draws content related to the level onto the screen. Game Engine Description This is the top-level controller. It activates controllers based on the current game mode. It is the thinnest of the controllers. Single Module Justification There needs to be some connection between different game modes. This delegates the main updating to the appropriate controller, loading and unloading components as needed. Story Controller Description A controller of the story mode that updates the player’s resources according to his/her scores from each of the levels of the story. Also responsible for calling story view to update the map drawing and other HUD displays. Single Module Justification This is a controller dedicated to the story mode of the game. Story Model Description A model that maintains the current state of the player’s progress in the story mode, including information of the current player’s manageable resources, recruited musicians, unlocked/succeeded levels, and current state of the map (accessible and inaccessible paths). Single Module Justification This is a model that stores the state of the story mode of the game. Input Buffer Model Description It is necessary for the game to save a buffer of input collected over different frames so the game may score the player’s accuracy on each beat. The Wiimote and Mouse control schemes provide data in fundamentally different ways; Input Buffer provides a standard interface for the rest of the game to acquire position, velocity, acceleration, and button state. Single module Justification This model simply stores a collection of positions, velocities, accelerations, and button states until the Movement Evaluator is ready to score those inputs and flush the buffer. Movement Queue Description Movement Queue contains data on some action to be performed, such as a shake or a wave or no operation. Curves and straight lines on screen can be represented. Single Module Justification This is a model because it is the only class that stores information about actions to be performed and patterns to be drawn. Movement Evaluator Model Description This is a model that compares a list of input states to a given movement path and scores how well they match - the higher the score, the better the match. A threshold is set up to determine success or failure of the last movement based on the accuracy score. The evaluator can also take in other elements, such as volume, when computing the accuracy. Single Module Justification This is a model because it handles self-contained calculations using data from Input Buffer and Movement Queue that compute the score obtained after each movement is finished . Level Model Description Each level model represents a playable level of the game. It stores the essential logical and visual information of the current level. Single Module Justification It is a container for the state and player progress of a game level. Baton View Description This contains the drawing code for the baton, which is essentially a cursor. The baton gains extra visual effects, like sparkles, when the player is making many consecutively accurate movements. Single Module Justification The baton contains no logic of its own: it is essentially a cursor which changes appearance as the level progresses. Movement View Description It contains the drawing code for Movement Queue model. Single Module Justification This is a separate view module that is dedicated to provide visual cues to players for the upcoming events. Stage View Description This calls the level model to get the background for the current level, score of the current level, and coordinates of the musicians and draws them onto the screen. Single Module Justification This is a separate view module responsible for displaying visual elements other than movement of the current level. Story View Description This draws a dialog box and a background, to illustrate the story between levels. Single Module Justification All the drawing code of this scene is extracted to one place, because it is primarily an artist and game designer responsibility, with no real programming logic needed. Menu Controller Description This allows user navigation from the title screen to the map screen, and from the play level screen back to the pause screen to the title screen. Single Module Justification All menu systems are very similar in user interaction: a user has a list of text options and selects one of them to navigate to another menu or game mode. Thus, a single controller can render different views (menus) easily. Pause Screen View Description Draws a simple pause screen to return to the game or exit to the title screen. Single Module Justification The pause screen is a simple but necessary view; it is simply something to cover up the screen as the player takes a break. Title Screen View Description This is another simple view to draw the title screen artwork and present options to either exit or continue into story mode. Single Module Justification The title screen has very few options; it is primarily for the artists to make a good first impression of the game. Module Dependency Graph Activity Diagram Class Interfaces Mouse Controller Fields InputBuffer buffer ● A reference to the input buffer Functions void Update(GameTime t) ● Reads the mouse position ● Creates a corresponding InputState ● Adds the InputState to the buffer Wii Controller Fields InputBuffer buffer ● A reference to the input buffer Functions void Update(GameTime t) ● Reads the Wiimote position ● Creates a corresponding InputState ● Adds the InputState to the buffer Level Controller Fields Level l ● A reference to the level model that collaborates with this controller Functions void Update(GameTime t) ● Calculates the current beat ● If the beat is changed, adds and removes movements from the list as needed void Draw(SpriteBatch sp) ● Calls the Draw() function for each of the movement in the draw set Story Controller Fields Story s ● A story model associated with the story controller Functions void Initialize() ● Initializes a new story Model void SetStory() ● sets the story model that is currently associated with this controller voidUpdate(GameTime gameTime) ● Updates the story model according to user input void Draw(SpriteBatch spriteBatch) ● Calls Draw() method from StoryView Game Engine Fields SpriteBatch spriteBatch ● Used to draw onto screen Baton baton ● The baton used to represent player movement Functions void Initialize() ● Initializes the field varibles void LoadContent() ● Calls LoadContent() methods of baton and level void Update(GameTime gameTime) ● Calls Update(GameTime gameTime) methods of baton and level void Draw(SpriteBatch spriteBatch) ● Calls Draw(SpriteBatch spriteBatch) methods of baton and level Input Buffer Fields List buffer ● A list of InputStates received from mouse/Wiimote controller containing information of baton position, velocity and acceleration Functions void Add(InputState istate) ● Adds istate to buffer List Buffer ● Returns the buffer void Clear() ● Clears the buffer Movement Queue Fields Movement.Type Type ● Type of this movement - shake, wave, or noop (i.e. no operation) int StartBeat, EndBeat ● Defines the duration in which the movement should be carried out int ShowBeat, FadeBeat ● Defines the duration in which the movement should be displayed on the screen Point StartCoordinate, EndCoordinate ● The start and end coordinates of the movement Movement Evaluator Fields IEnumerable states ● A collection of input detections, which together form a movement Movement currentMovement ● A movement object currently being evaluated Functions float Accuracy(Movement m, IEnumerable input, GameTime t) ● Returns a floating number 0 to 1 which indicates how well the input is matching the movement ● Can use game time in case we want more granularity, for example, indicate in midbeat how well a player is doing. Level Model Fields Stopwatch watch ● Keeps track of the time after the level starts to calculate the value of the current beat int currentBeat ● The current beat int score ● The current score int beatTime ● The BPM of the song LinkedList actionList ● The list of the actions waiting to be displayed to and performed by the player HashSet drawSet ● The set of movements that are currently being displayed/drawn to the screen Movement currentMovement ● The current movement that is expected to be performed by the player Functions void LoadContent() ● Loads the level from an XML file, which contains the MP3’s path and the list actions ● Loads the actions into a movement list. int Score ● Gets the current score int Beat ● Gets the current beat Movement currentMovement ● Gets the movement that is currently expected to be performed by the player Story Model Fields int gold ● Player’s current gold int fame ● Player’s current fame HashSet musicians ● Musicians that have been recruited int elapsedTime ● Time elapsed since the beginning of the game LinkedList stations ● The list of the individual “station” on the game map. When player is in contact with one of the stations, it triggers dialogs with NPC’s and introduces the player to new game levels Station currentStation ● The station the player is currently located at StoryModel.ModeType mode ● Indicates which mode the story is currently in Functions void LoadContent() ● Loads the game map and XML files that contain saved game status (current gold, fame, player’s name, gametime, etc.) bool Move(Direction d) ● Allows the player to move in one direction, returns whether that movement has succeeded void loadStation() ● Loads the content (includes story, associated game level, etc) of the current station void setCurrentStation(Station s) ● Sets the current station to s void Evaluate(int score) ● Updates the player’s gold and fame according to the score of a played level Baton View Functions void Draw(GameTime t) ● Draws the baton onto screen using the position from user input void LoadContent() ● Loads the baton texture void Update(GameTime t) ● Collects input from input device ● Stores the input into an InputState structure and adds it to the collection IEnumerable CurrentInput() ● Returns a list of input states for the last beat, to be evaluated and scored void Flush() ● Clears the list of input states Movement View Functions void LoadContent() ● Loads the movement texture void Draw(Movement m, SpriteBatch sb) ● Draws the input movement onto the screen Story View Functions void LoadContent() ● Loads the textures needed for the story mode void Draw(Story s, SpriteBatch sb) ● Draws the input state of the story mode of the game onto the screen Stage View Functions void LoadContent() ● Loads the textures needed for the stage void Draw(Level l, SpriteBatch sb) ● Draws/updates the background, musician characters onto the screen Data Representation Model The XNA Content Pipeline is leveraged for XML data. By providing the “Asset Type” and a class name, the framework automatically serializes object fields. Saved Game File A saved game uses the “SaveData” class for serialization. It is an XML file with the following tags: Game Level File A level uses the LevelData class for serialization. The serialized LevelData is an XML file with the following tag structure: Third-Party Libraries Codeplex Wii Library This library allows for the game to read the Wiimote as an input device. The library provides access to a WiimoteState object, which provides the gyroscope acceleration in three dimensions, infrared position in two dimensions, and the Boolean button states. We can also read from the nun-chuck extension, which provides Boolean button states and a joystick position in two dimensions. All vectors are available in a normalized (0 to 1 float) format, as well as a raw format. The acceleration will be used to detect shaking movements; the infrared, to detect waving motions. Some movements will also require a button press, which we can check as well.